import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xvideos/assets_tool/images.dart';
import 'package:xvideos/hj_utils/widget_utils.dart';
import 'package:xvideos/tools_base/widget/net_image_widget.dart';

import '../../../hj_model/video_model.dart';
import 'pics_detail_page.dart';

class PicSetsCell extends StatelessWidget {
  final VideoModel? videoModel;
  final Function? callback;

  final bool allBorder;

  PicSetsCell({
    this.videoModel,
    this.callback,
    this.allBorder = false,
  });

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {
        if (callback != null) {
          callback?.call();
        } else {
          Get.to(PicsDetailPage(id: videoModel?.id), preventDuplicates: false);
        }
      },
      child: Column(
        children: [
          Expanded(
            child: Stack(
              fit: StackFit.expand,
              children: [
                ClipRRect(
                  borderRadius: allBorder
                      ? BorderRadius.circular(8)
                      : BorderRadius.only(
                          topLeft: Radius.circular(8),
                          topRight: Radius.circular(8),
                        ),
                  child: NetworkImageLoader(
                    imageUrl: videoModel?.cover ?? '',
                    compress: true,
                  ),
                ),
                Container(
                  height: 30,
                  alignment: Alignment.bottomCenter,
                  decoration: BoxDecoration(
                    gradient: LinearGradient(
                      colors: [Colors.black54, Colors.transparent],
                      begin: Alignment.bottomCenter,
                      end: Alignment.topCenter,
                    ),
                    borderRadius: allBorder
                        ? BorderRadius.circular(8)
                        : BorderRadius.only(
                            topLeft: Radius.circular(8),
                            topRight: Radius.circular(8),
                          ),
                  ),
                  child: Padding(
                    padding: EdgeInsets.only(left: 4, right: 4, bottom: 4),
                    child: Row(
                      children: [
                        Row(
                          children: [
                            Image.asset('count_eye.png'.communityPath, width: 16),
                            SizedBox(width: 2),
                            Text(
                              videoModel?.playCount?.humanizeFormat ?? "",
                              style: TextStyle(
                                color: Colors.white,
                                fontSize: 12,
                              ),
                            ),
                          ],
                        ),
                        Spacer(),
                        Container(
                          padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 2),
                          decoration: BoxDecoration(
                            color: Colors.black.withOpacity(0.5),
                            borderRadius: BorderRadius.circular(3),
                          ),
                          child: Row(
                            children: [
                              Image.asset('find_pics.png'.findPath, width: 16),
                              SizedBox(width: 2),
                              Text(
                                '${videoModel?.seriesCover?.length ?? 0}',
                                textAlign: TextAlign.justify,
                                style: TextStyle(
                                  color: Colors.white,
                                  fontSize: 12,
                                  fontWeight: FontWeight.w400,
                                ),
                              ),
                            ],
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              ],
            ),
          ),
          Container(
            padding: EdgeInsets.symmetric(horizontal: 7, vertical: 6),
            alignment: Alignment.centerLeft,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.only(
                bottomLeft: Radius.circular(8),
                bottomRight: Radius.circular(8),
              ),
            ),
            child: Text(
              '${videoModel?.title}',
              maxLines: 1,
              overflow: TextOverflow.ellipsis,
              style: TextStyle(
                color: Colors.white,
                fontSize: 14,
                fontWeight: FontWeight.w400,
              ),
            ),
          ),
        ],
      ),
    );
  }
}
